package com.itheima.udp3;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;

/*
发送端
不断的键盘录入发送    886  结束
 */
public class FasongClient {

    public static void main(String[] args) throws IOException {
        //创建发送对象
        DatagramSocket ds = new DatagramSocket();
        while (true) {
            //创建数据对象
            Scanner sc = new Scanner(System.in);
            String s = sc.nextLine();

            //224.0.1.0~224.255.255.255 组播地址
            DatagramPacket dp = new DatagramPacket(s.getBytes(), s.getBytes().length, InetAddress.getByName("224.0.1.0"), 8888);

            //发送
            ds.send(dp);
            if("886".equals(s)){
                break;
            }
        }

        //释放资源
        ds.close();


    }
}
